package edu.mtu.citizenscience.cs.notepad.activity.noteslist;

import com.androidquery.AQuery;

import edu.mtu.citizenscience.cs.notepad.activity.R;

import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/**
 * @author Corbin Uselton <corbinu@cwuselto@mtu.edu>
 * @copyright (c) 2012 MichiganTech <http://www.mtu.edu>
 * @since 1.0
 * 
 * Dialog for informing the user that they need to enable the GPS for this app
 */
public class EnableGPSDialog extends DialogFragment {
	// android-query library
	private AQuery aq;
	
	/**
	 * Create view for the GPS Dialog
	 * 
	 * @param inflater - LayoutInflater - for inflating views
	 * @param container - ViewGroup - the dialogs view container
	 * @param savedInstanceState - Bundle - Bundle with launch info
	 * @return View - the View for the fragment's UI, or null
	 */
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
    {
    	// inflate the gps dialog view
        View view = inflater.inflate(R.layout.dialog_activate_gps, container, false);
        
        // create android query instance
        this.aq = new AQuery(this.getActivity(), view);
    	
        // set the dialog title
    	this.getDialog().setTitle("GPS Not Activated");
    	
    	// set button handlers
    	this.aq.id(R.id.activateButton).clicked(this, "activateClicked");
    	this.aq.id(R.id.cancelButton).clicked(this, "cancelClicked");
    	
    	// return the inflated view
        return view;
    }
    
    /**
	 * onClick handler for activate button
	 * 
	 * @param void
	 * @return void
	 */
	public void activateClicked()
	{
		// start the android location settings activity
        this.startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
	}

	/**
	 * onClick handler for cancel button
	 * 
	 * @param void
	 * @return void
	 */
    public void cancelClicked()
    {
    	// dismiss the dialog
    	this.dismiss();
    }

}